package org.jeecg.modules.relation.relclssubtearoom.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.relation.relclassstudent.vo.RelClassesAndStudentsVO;
import org.jeecg.modules.relation.relclssubtearoom.entity.RelClassSubjectTeacher;
import org.jeecg.modules.relation.relclssubtearoom.mapper.RelClassSubjectTeacherMapper;
import org.jeecg.modules.relation.relclssubtearoom.service.IRelClassSubjectTeacherService;
import org.jeecg.modules.relation.relclssubtearoom.vo.RelClassSubjectTeacherVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: rel_class_subject_teacher
 * @author: baochangrong
 * @Date: 2022-02-16
 * @Version: V1.0
 */
@Service
public class RelClassSubjectTeacherServiceImpl extends ServiceImpl<RelClassSubjectTeacherMapper, RelClassSubjectTeacher> implements IRelClassSubjectTeacherService {

    @Autowired
    private RelClassSubjectTeacherMapper relClassSubjectTeacherMapper;

    @Override
    public IPage<RelClassSubjectTeacherVO> queryAllList(Page<RelClassSubjectTeacherVO> page,RelClassSubjectTeacher relClassSubjectTeacher, String tenantId) {
         List<RelClassSubjectTeacherVO> relClassSubjectTeacherVOList = relClassSubjectTeacherMapper.queryAllList(page, relClassSubjectTeacher,tenantId);
         return page.setRecords(relClassSubjectTeacherVOList);
    }
    /**
     * 查询老师-科目-班级-教室的分配关系，应用与科目-老师的联动下拉框
     * @param relClassSubjectTeacherVO
     * @param queryParam,其中querySubjectSysDictFlag 是否需要查询科目的字典码：例如课间操、眼保健操等字典码
     * @return
     */
    public List<RelClassSubjectTeacherVO> queryTeacherClassListBySubject(@Param("relClassSubjectTeacherVO") RelClassSubjectTeacherVO relClassSubjectTeacherVO, @Param("queryParam") Map<String,String> queryParam){
        /*默认查询：是否查询科目的系统字典数据 ：1是，其他的都是否，默认查询字典数据，方便在编辑课表、分配班级的任教老师和教室场地时候使用 */
        if(oConvertUtils.isEmpty(queryParam) ){
            queryParam = new HashMap<String,String>();
            queryParam.put("querySubjectSysDictFlag","1");
        }
        else if(oConvertUtils.isEmpty(queryParam.get("querySubjectSysDictFlag"))){
            queryParam.put("querySubjectSysDictFlag","1");
        }
        return relClassSubjectTeacherMapper.queryTeacherClassListBySubject(relClassSubjectTeacherVO,queryParam);
    };

    public int insertUpgradeRelClassSubjectTeacher(RelClassSubjectTeacherVO relClassSubjectTeacherVO){
        return relClassSubjectTeacherMapper.insertUpgradeRelClassSubjectTeacher(relClassSubjectTeacherVO);
    }

}
